﻿// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	: FI.Net Application Framework
// COMPONENT ID	: FI.Architecture.Server
// COMPONENT DESC:		
//
// CREATED DATE/BY:		18 Aug 2018 / Tian Mi
//
// REVISION HISTORY:	DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================

using FI.Core;
using FI.Core.IoC;

namespace FI.Architecture.Server
{
    /// <summary>
    /// The base class for all services.
    /// </summary>
    public class ServiceBase : ApplicationContextAwareObject, IServiceLocatableObject
    {
        /// <summary>
        /// Gets the service locator.
        /// </summary>
        /// <value>The service locator.</value>
        public IServiceLocator ServiceLocator
        {
            get { return ServiceLocatorFactory.GetServiceLocator(); }
        }
    }

    /// <summary>
    /// The base class for all serivces with a typed BC object.
    /// </summary>
    /// <typeparam name="TBusinessComponent">The type of the BC object.</typeparam>
    public class ServiceBase<TBusinessComponent> : ServiceBase where TBusinessComponent : BusinessComponentBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceBase&lt;TBusinessComponent&gt;"/> class.
        /// </summary>
        /// <param name="bc">The bc object.</param>
        public ServiceBase(TBusinessComponent bc)
        {
            this.BusinessComponent = bc;
        }

        /// <summary>
        /// Gets or sets the BC object.
        /// </summary>
        /// <value>The BC object.</value>
        public TBusinessComponent BusinessComponent { get; set; }
    }
}
